package com.mvvmhabit.org.binding.viewadapter.loading

import androidx.databinding.BindingAdapter
import com.mvvmhabit.org.binding.command.BindingCommand
import com.mvvmhabit.org.custom.LoadingLayout

@BindingAdapter(value = ["loadState"])
fun setLoadState(loadingLayout: LoadingLayout, loadState: Int) {
    loadingLayout.setErrorType(loadState)
}

@BindingAdapter(value = ["onClickAgainLoadCommand"])
fun onClickLoadCommand(layout: LoadingLayout, loadCommand: BindingCommand<Any>) {
    layout.setOnLayoutClickListener {
        loadCommand.execute()
    }
}